﻿using System;
using System.Data;
using System.Collections.Generic;

namespace EnterpriseFund.BLL
{
    /// <summary>
    /// 业务逻辑类PrvIPAccessList 的摘要说明。
    /// </summary>
    public class PrvIPAccessList
    {
        private readonly DAL.PrvIPAccessList dal = new DAL.PrvIPAccessList();
        public PrvIPAccessList()
        { }
        #region  成员方法

        /// <summary>
        /// 得到最大ID
        /// </summary>
        public int GetMaxId()
        {
            return dal.GetMaxId();
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string FEntityNo, int FAccessIPID)
        {
            return dal.Exists(FEntityNo, FAccessIPID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.PrvIPAccessList model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Model.PrvIPAccessList model)
        {
            dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(string FEntityNo, int FAccessIPID)
        {

            dal.Delete(FEntityNo, FAccessIPID);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.PrvIPAccessList GetModel(string FEntityNo, int FAccessIPID)
        {

            return dal.GetModel(FEntityNo, FAccessIPID);
        }

  

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.PrvIPAccessList> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.PrvIPAccessList> DataTableToList(DataTable dt)
        {
            List<Model.PrvIPAccessList> modelList = new List<Model.PrvIPAccessList>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.PrvIPAccessList model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.PrvIPAccessList();
                    if (dt.Rows[n]["FAccessIPID"].ToString() != "")
                    {
                        model.FAccessIPID = int.Parse(dt.Rows[n]["FAccessIPID"].ToString());
                    }
                    model.FEntityNo = dt.Rows[n]["FEntityNo"].ToString();
                    if (dt.Rows[n]["FStartIP"].ToString() != "")
                    {
                        model.FStartIP = long.Parse(dt.Rows[n]["FStartIP"].ToString());
                    }
                    if (dt.Rows[n]["FEndIP"].ToString() != "")
                    {
                        model.FEndIP = long.Parse(dt.Rows[n]["FEndIP"].ToString());
                    }
                    model.FNote = dt.Rows[n]["FNote"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  成员方法
    }
}

